

<!--- <cfinclude template="../functions.cfm">
<cfinclude template="../authentication.cfm"> --->

<cfset BASE = CreateObject("component", "#session.rootDir#.cfc.base") />

<cfoutput>
<!---HTML header, css links, js links, and page title--->
#BASE.htmlTerminationHeader(
    "/jquery/ui-1.8.5/jquery-ui.min.js", <!---JS links--->
    "/jquery/ui-1.8.5/themes/cupertino/jquery-ui.css", <!---CSS links--->
    "Step 2:  HR - Confirmation Request 3", <!---Page Title--->
    "Status" <!---Active Nav Link--->
)#
<!---HTML header, css links, js links, and page title--->
</cfoutput>

<cfif Session.bolAuth EQ True and (Session.strAuthType EQ Session.LIAISONS or Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR)>

	<cfset ORG_SCF = 117>	
	<cfset intTermReqID = 0>
    <cfset intRosettaID = 0>
	<cfset intTermTypeID = 0>
	<cfset intESReasonID = 0>
	<cfset intEmpStatusID = -10133>
	<cfset intRehireElig = 0>
	<cfset intFileTypeID = 0>
	<cfset strManagerName = "">
	<cfset strEmpName = "">
	<!---cfset strComments = ""--->
	<cfset strManagerComments = "">
	<cfset strComments = "">
	<cfset strFile = "">
	<cfset strDIR = "">
	<cfset strCheck = "no">
	<cfset dteTerm = dateformat(now(),'mm/dd/yyyy')>
	<cfset dteCOBRA = dateformat(now(),'mm/dd/yyyy')>
	     
		 
	<cfif isdefined("Session.intTermReqID")>
		<cfset variables.intTermReqID = Session.intTermReqID>
		
		<cfquery name="qryGetTermDetails" datasource="#Session.DataSource#">
			scf_GetTermDetails #intTermReqID#, 18
		</cfquery>
		
		<cfoutput query="qryGetTermDetails">
			<cfset intRosettaID = qryGetTermDetails.RosettaID>
			<cfset intSubmittedByID = qryGetTermDetails.ActionByID>
			<cfset dteSubmitted = dateformat(qryGetTermDetails.ActTimeStamp,'mm/dd/yyyy') & ' ' & timeformat(qryGetTermDetails.ActTimeStamp,'H:MM:ss TT')>
			<cfset intTermTypeID = qryGetTermDetails.TermTypeID>
			<cfset intESReasonID = qryGetTermDetails.EmpStatusReasonCode>
			<cfset intEmpStatusID = qryGetTermDetails.EmpStatusIDNo>
			<cfset intRehireElig = qryGetTermDetails.RehireElig>
			<cfset strManagerComments = qryGetTermDetails.Notes>
			<cfset strCheck = "no">
			<cfset dteTerm = dateformat(qryGetTermDetails.TermDate, 'mm/dd/yyyy')>
			<cfset dteCOBRA = dateformat(qryGetTermDetails.COBRAEndOfMonth, 'mm/dd/yyyy')> 	
			
			<cfset objManager = SCF_EMPLOYEE_GetEmployee (intSubmittedByID)>
			<cfset strManagerName = objManager.FullName>
			
			<cfset objTerm = SCF_EMPLOYEE_GetEmployee (intRosettaID)>
			<cfset strEmpName = objTerm.FullName>
		</cfoutput>   
	
		<cfquery name="qryGetFilePath" datasource="#Session.DataSource#">
			scf_GetFilePath
		</cfquery>
		<cfset strDIR = qryGetFilePath.Directory>
		
	<cfelse>
		<cflocation url="Step2-HRConfirmRequest1.cfm"> 
		
    </cfif>
	
            
	<cfset variables.intTermReqID = Session.intTermReqID>
	<cfif isdefined("form.cmbFileType")>
		<cfset intFileTypeID = Form.cmbFileType>
		
		<cfif form.FileUpload NEQ ''>
			<cffile action='upload' filefield='FileUpload' destination='#strDIR#' nameconflict='makeunique'/>		
				
			<cfset strFile = cffile.ServerFile>
			<cfquery name = "qryAddFile" datasource="#Session.DataSource#">
				scf_InsertFile NULL, #intTermReqID#, '#strFile#', #intFileTypeID#, #Session.intUserRosettaID#
			</cfquery>
		</cfif>
	<cfelseif isdefined("Form.txtComments")>
		<!--- Advance to the next step --->   
		<!--- Insert step record ---> 
		
		<cfset strComments = Form.txtComments>
		<cfquery name="qryGetTermDetails" datasource="#Session.DataSource#">
			scf_GetTermDetails #intTermReqID#, 20
		</cfquery>
		<cfset variables.intActionStepID = qryGetTermDetails.ActionStepID>
		  
        <cfquery name="qryInsertTermAction" datasource="#Session.DataSource#">
            scf_UpdateAction #intActionStepID#, #Session.intUserRosettaID#, '#strComments#'
        </cfquery>                           
		<cfquery name="qryNonSCFStep1InsertAction" datasource="#Session.DataSource#">
			scf_InsertAction  NULL, 22, NULL, NULL, #intTermReqID#
		</cfquery>   
		<cflocation url="Step3-ExecTerm.cfm"> 
    </cfif>


    
    <cfquery name="qryGetAllEmployees" datasource="SCF_General">
    	Select RosettaID, LastNameFirst 
		From func_GetUsers(0,0,0)
		Order By LastNameFirst
    </cfquery>
     
    <cfquery name="qryGetTermTypes" datasource="#Session.DataSource#">
    	scf_SCFVM18_GetPersonCodes 'TT'
    </cfquery>
	
    <cfquery name="qryGetES" datasource="#Session.DataSource#">
    	scf_SCFVM18_GetPersonCodes 'ES'
    </cfquery>
    <cfquery name="qryGetEmpStatus" dbtype="query">
    	Select * 
		From qryGetES
		Where PersonCodeIDNo in (-10133, -10132)
    </cfquery>
	
	
	<cfquery name="qryGetReasonCodes1" datasource="#Session.DataSource#">
		scf_SCFVM18_GetReasonCodes 'ES'
	</cfquery>
	<cfquery name="qryGetESReasonCodes" dbtype="query">
		Select * From qryGetReasonCodes1
		Where ReasonCodeIDNo not in (3,5,6,56)
	</cfquery>    
    
	
	<cfquery name="qryGetFiles" datasource="#Session.DataSource#">
		scf_GetFiles #intTermReqID#
	</cfquery>
	<cfquery name="qryGetFileTypes" datasource="#Session.DataSource#">
		scf_GetFileTypes 2
	</cfquery>
	
    <cfoutput>
    <body>
    <!-- start header -->
        <cfinclude template="../header.cfm"/>
    <!-- end header -->
    
    <!-- start page -->
    <div id="page">	
        <div id="menu">
        	<cfinclude template="HeaderOptions.cfm"/>
        </div>
        <!-- start content -->
        <div id="content">
            <div class="post">
                <!---p class="date">#dateformat(now(), "mmmm")# <b>#dateformat(now(), "d")#</b></p--->
                <h1 class="title">Step 1:  Termination Request</h1>
                <div class="entry">    
                	 Welcome, #Session.arrEmpInfo.FirstName# #Session.arrEmpInfo.LastName#.  
                	 In this step, you'll verify the termination information 
                	 submitted by the manager: <br /><br />     
				<cfform id="frmStep2" name="frmFL" method='POST' enctype='multipart/form-data'>
                <table width = 100%>
                	<tr>
                    	<td width =20%>
                        	Submitted By:
                        </td>
                    	<td>
                        	#strManagerName#
                        	<cfinput type="hidden" name="txtManagerName" value="#strManagerName#"/>
                        </td>
                    </tr>
                	<tr>
                    	<td width =20%>
                        	Submitted Date/Time:
                        </td>
                    	<td>
                        	#dteSubmitted#
                        	<cfinput type="hidden" name="txtDateSubmitted" value="#dteSubmitted#"/>
                        </td>
                    </tr>
                	<tr>
                    	<td width =20% valign="top">
                        	Comments:
                        </td>
                    	<td>
                        	#strManagerComments#
                        	<cfinput type="hidden" name="txtManagerComments" value="#strManagerComments#"/>
                        </td>
                    </tr>
                	<tr>
                    	<td colspan=2>
                        	<HR />
                        </td>
                    </tr>
                	<tr>
                    	<td width =20%>
                        	Employee:
                        </td>
                    	<td>
							#strEmpName#
                        	<cfinput type="hidden" name="txtRosetta" value="#intRosettaID#"/>
                        </td>
                    </tr>
                	<tr>
                    	<td>
                        	Termination Type:
                        </td>
                    	<td>
							<cfquery name="qryGetTermType" dbtype="query">
								Select PersonCode
								From qryGetTermTypes
								Where PersonCodeIDNo = #intTermTypeID#
							</cfquery>                       	
                            #qryGetTermType.PersonCode#
                        </td>
                    </tr>
                	<tr>
                    	<td>
                        	Employee Status:
                        </td>
                    	<td>     
							<cfquery name="qryGetEmpStat" dbtype="query">
								Select PersonCode
								From qryGetEmpStatus
								Where PersonCodeIDNo = #intEmpStatusID#
							</cfquery>                     	
                            #qryGetEmpStat.PersonCode#                	
                        </td>
                    </tr>
                	<tr>
                    	<td nowrap="nowrap">
                        	Employment Status Reason:
                        </td>
                    	<td> 
							<cfquery name="qryGetESReasonCode" dbtype="query">
								Select ReasonCode
								From qryGetESReasonCodes
								Where ReasonCodeIDNo = #intESReasonID#
							</cfquery>                       	
                            #qryGetESReasonCode.ReasonCode#                      	
                        </td>
                    </tr>
                	<tr>
                    	<td>
							Rehire Eligible?                        	
                        </td>
                    	<td>
							<cfif intRehireElig EQ 1>
								YES
							<cfelse>
								NO
							</cfif>
                        </td>
                    </tr>
                	<tr>
                    	<td valign="top">
                        	Termination Date: 
                        </td>
                    	<td>
							#dteTerm#
                        </td>
                    </tr>
                	<tr>
                    	<td valign="top">
                        	COBRA Exp Date:
                        </td>
                    	<td>
							#dteCOBRA#
                        </td>
                    </tr>
                	<tr>
                    	<td colspan = 2>
							<fieldset>
							<legend>File Library</legend>
							<table width=100%>
								<TR>
									<TD width=5% nowrap="nowrap" valign="top">
										File Type:
									</TD>
									<TD width="75%">
										<cfselect name="cmbFileType" query="qryGetFileTypes" display="Name" value="ID"/> 									
									</TD>
									<TD>&nbsp;
										
									</TD>
								</TR>
								<TR>
									<TD width=5% nowrap="nowrap" valign="top">
										File:
									</TD>
									<TD width="75%">
										<cfinput type="file" name="FileUpload" required="yes" message="Please specify the file to upload." style="width:100%">										
									</TD>
									<TD align="right" valign="bottom">
										<cfinput name="cmdUpload" type="submit" value="Upload"> 
									</TD>
								</TR>	
								<tr>
									<td colspan=3>
										<HR />
									</td>
								</tr>	
								<TR>
									<TD colspan=3>
										<table width="100%">
											<TR>
												<TD rowspan="4" colspan=3 valign="top">
												<cfif qryGetFiles.recordcount EQ 0>
													<span class="failed" style="font-size:90%">No existing files associated with this termination request</span>
												<cfelse>
													<Table width=100%>
														<TR>
															<TD>
																<strong>File Type</strong>
															</TD>
															<TD width=1%>&nbsp;</TD>
															<TD>
																<strong>Date Submitted</strong>
															</TD>
															<TD width=1%>&nbsp;</TD>
															<TD>
																<strong>Submitted By</strong>
															</TD>
															<TD width=1%>&nbsp;</TD>
															<TD>
																<strong>File Name</strong>
															</TD>
														</TR>
													<cfloop query="qryGetFiles">
														<cfset strPath = strDIR & "\" & FileName>
														<cfset objEmp = SCF_Employee_GetEmployee(LoadedBy)>
														<cfset strLoadedBy = objEmp.FullName>
														<TR>
															<TD nowrap="nowrap">
																#Name#
															</TD>
															<TD>&nbsp;</TD>
															<TD nowrap="nowrap">
																#dateformat(DateLoaded, 'm/d/yyyy')#
															</TD>
															<TD>&nbsp;</TD>
															<TD nowrap="nowrap">
																#strLoadedBy#
															</TD>
															<TD>&nbsp;</TD>
															<TD nowrap="nowrap">										
																<a href="#strPath#" target="_blank">#FileName#</a>
															</TD>
														</TR>
													</cfloop>
													</Table>
												</cfif>		
												</TD>
											</TR>
										</table>
									</TD>
								</TR>						
							</table>    
							</fieldset>                	
                        </td>
					</tr>
				</table>
				</cfform>
				<cfform id="frmStep2" name="frmFL" method='POST' enctype='multipart/form-data'>
				<table width="100%">
                    <tr>
                    	<td align="right" width="100%">
							<cftextarea name="txtComments" value="#strComments#" style="width:98%"/>
                        </td>
                    </tr>  
                    <tr>
                    	<td  align="right">
							<cfinput type="button" name="cmdBack" value="<< Back" tabindex="75" onclick="window.location='Step2-HRConfirmRequest2.cfm'">
                        	<cfinput type="submit" name="cmdFinish" value="Finish (Terminate)" tabindex="80">
                        </td>
                    </tr>  
                </table>
				</cfform>
                </div>
            </div>
        </div>
        <!-- end content -->
</cfoutput>

<cfelse>
    <cfinclude template="../denied.cfm">
</cfif>

<cfoutput>
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
#BASE.htmlTerminationFooter()#
<!---HTML footer, closes html and body tags.  Any footer info goes here--->
</cfoutput>